package com.zengshuai.miniprogrambackend.Controller;


import com.zengshuai.miniprogrambackend.Entity.Employee;
import com.zengshuai.miniprogrambackend.Entity.Image;
import com.zengshuai.miniprogrambackend.Entity.Part;
import com.zengshuai.miniprogrambackend.Mapper.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private EmployeeMapper employeeMapper;

    @GetMapping("/login")
    public boolean login(String employeeid, String password) {

        System.out.println(employeeMapper.login(employeeid, password));

        return employeeMapper.login(employeeid, password);

    }

    @GetMapping("/getemployeeinfo")
    public Employee getemployeeinfo(String employeeid) {

        return employeeMapper.getemployeeinfo(employeeid);
    }

    @GetMapping("/getparts")
    public List<Part> getparts(String serviceid, String category) {

        System.out.println(employeeMapper.getpartsbycategory(serviceid, category));
        return employeeMapper.getpartsbycategory(serviceid, category);
    }

    @GetMapping("/getimages")
    public List<Image> getimages(String serviceid,String category){

        return employeeMapper.getimages(serviceid,category);
    }

    @GetMapping("/charge")
    public void charge(String actualpayment,String chargedetail,String id){

        System.out.println(actualpayment+chargedetail);

        employeeMapper.charge(actualpayment,chargedetail,id);

    }

}
